﻿#include "ImSignalBlock.h"

#include "../Widgets/UiWidgetBase.h"

#include <QDebug>

namespace GeneralUI {

	ImSignalBlock::ImSignalBlock()
	{

	}

	ImSignalBlock::~ImSignalBlock()
	{
		foreach(QObject* obj, m_objs)
		{
			if (obj)
			{
				if (obj->inherits("ciqtek::UiWidgetBase"))
				{
					UiWidgetBase *curObj = qobject_cast<UiWidgetBase *>(obj);
					curObj->blockSignals(false);
				}
				else
				{
					obj->blockSignals(false);
				}
			}
		}
	}

	ImSignalBlock &ImSignalBlock::operator<< (QObject *obj)
	{
		if (obj)
		{
			m_objs.append(obj);

			if (obj->inherits("ciqtek::UiWidgetBase"))
			{
				UiWidgetBase *curObj = qobject_cast<UiWidgetBase *>(obj);
				curObj->blockSignals(true);
			}
			else
			{
				obj->blockSignals(true);
			}
		}
		return *this;
	}

}//namespace OfUI
